package cglib;

public class ThreadState {
    public static void main(String[] args) {
        Object obj=new Object();

        new Thread(()->{
            synchronized (obj){
                try {
                    System.out.println("线程1调用wait()");
                    obj.wait();
                    System.out.println("线程1结束wait()");
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        },"thread——1").start();
        Thread thread = new Thread();

        new Thread(()->{
            synchronized (obj){
                System.out.println("线程2调用notify");
                obj.notify();
                System.out.println("线程2结束nofity");
                try {
                    Thread.sleep(5000L);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        },"thread——2").start();
    }
}


